package unclassified.simple;

public class DayOfTheWeek_1185 {

    public String dayOfTheWeek(int day, int month, int year) {
        String[] res = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
        int[] nums = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int ans = 4;
        for (int i = 1971; i < year; i++) {
            ans += (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0) ? 366 : 365);
        }

        for (int i = 1; i < month; i++) {
            ans += nums[i - 1];
            if (i == 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))) {
                ans++;
            }
        }
        ans += day;

        return res[ans % 7];
    }
}
